//
//  YMPDFInfo.m
//  TestDemo
//
//  Created by fantasy on 16/6/26.
//  Copyright © 2016年 goappbox. All rights reserved.
//

#import "YMPDFInfo.h"

@implementation YMPDFInfo

- (void)appliedToPDFObject:(CGPDFObjectRef)object forKey:(NSString *)key {
    CGPDFObjectType type = CGPDFObjectGetType(object);
    if (type != kCGPDFObjectTypeString) {
        return;
    }
    CGPDFStringRef string;
    CGPDFObjectGetValue(object, type, &string);
    if ([key isEqualToString:@"CreationDate"] || [key isEqualToString:@"ModDate"]) {
        self[key] = [self dateFromValue:string];
    } else {
        self[key] = [self stringFromValue:string];
    }
}

- (void)appliedAllObject {
    self.title = self[@"Title"];
    self.author = self[@"Author"];
    self.subject = self[@"Subject"];
    self.keywords = self[@"Keywords"];
    self.creator = self[@"Creator"];
    self.producer = self[@"Producer"];
    self.creationDate = self[@"CreationDate"];
    self.modDate = self[@"ModDate"];
}

@end
